home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / boss_sup.arc / WN_FRMGE.C < prev    next >
C/C++ Source or Header  |  1991-01-14  |  11KB  |  254 lines

  1. /*
  2. ** The Window BOSS's Data Clerk
  3. ** Copyright (c) 1988 - Philip A. Mongelluzzo
  4. ** All rights reserved.
  5. **
  6. ** wn_frmget - Get (read) data entry form
  7. **
  8. ** Copyright (c) 1988 - Philip A. Mongelluzzo
  9. ** All rights reserved.
  10. **
  11. */
  12.  
  13. #include "windows.h"                    /* standard stuff */
  14.  
  15. /*
  16. *************
  17. * wn_frmget *
  18. *************
  19. */
  20.  
  21. /*
  22. ** wn_frmget(frm)
  23. **
  24. **    int     nfields - number of fields in form.
  25. **
  26. ** RETURNS:
  27. **
  28. **    TRUE  - indicating all fields of the form in question have been
  29. **            fetched and verified (where required).
  30. **
  31. **    ESC_CODE - indicating ESCape was pressed and form processing
  32. **            was terminated.
  33. **
  34. **      or
  35. **
  36. **    Never Returns!!
  37. **
  38. ** NOTES:
  39. **
  40. **    This code can be used as is or can be customized to suite each
  41. **    applications need.  The section to customize is at the tail end
  42. **    of this file.  As distributed, logic diplays all prompts and
  43. **    display fields, positions to the first field, performs data
  44. **    entry on a field by field basis from the first to the last 
  45. **    (allowing editing along the way), asks for a confirmation to
  46. **    accept the fields on the form after the last field is entered,
  47. **    either accepts the form or drops into edit mode for all the
  48. **    fields on the form starting at the first field.
  49. **
  50. **    wn_frmget will not return until all data has been entered and
  51. **    verified (where required).
  52. **    
  53. **    This routine must be called after wn_frmopn, and before wn_frmcls.
  54. **
  55. */
  56.  
  57. /*
  58. *************
  59. * wn_frmget *
  60. *************
  61. */
  62.  
  63. #define FLD frm[indx]                   /* some shorthand */
  64.  
  65. wn_frmget(frm)                          /* input form processor */
  66. WIFORM frm;                             /* array of field pointers */
  67. {
  68. int indx;                               /* input field index */
  69. int rv;                                 /* wn_g???'s return value */
  70. int c;                                  /* scratch */
  71. WINDOWPTR wn;                           /* my OWN window */
  72.  
  73. static char *msg = "[Press ENTER to Accept, any other key to Edit]";
  74.  
  75.   wni_frmflg = TRUE;                    /* set initial state */
  76.                                         /* to display only */
  77.  
  78. begin:
  79.   indx = 0;                             /* reset index */
  80.   while(TRUE) {                         /* fetch input fields */
  81.     if(!FLD->fcode) break;              /* all done */
  82.     switch (FLD->fcode) {               /* based on function code */
  83.       case GDATE:
  84.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  85.           wns_ierr("wm_frmget@GDATE");
  86.         rv = wn_gdate(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  87.                       FLD->col, FLD->prmpt, 
  88.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  89.                       FLD->v3.vip, FLD->v4.vcp,
  90.                       FLD->v5.vcp,FLD->v6.vcp);
  91.         break;
  92.       case GTIME:
  93.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  94.           wns_ierr("wm_frmget@GTIME");
  95.         rv = wn_gtime(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  96.                       FLD->col, FLD->prmpt, 
  97.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  98.                       FLD->v3.vip, FLD->v4.vcp,
  99.                       FLD->v5.vcp,FLD->v6.vcp);
  100.         break;
  101.       case GINT:
  102.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  103.           wns_ierr("wm_frmget@GINT");
  104.         rv = wn_gint(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  105.                      FLD->col, FLD->prmpt, 
  106.                      FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vi, 
  107.                      FLD->v3.vi, FLD->v4.vi, FLD->v5.vcp,
  108.                      FLD->v6.vcp,FLD->v7.vcp);
  109.         break;
  110.       case GUINT:
  111.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  112.           wns_ierr("wm_frmget@GUINT");
  113.         rv = wn_guint(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  114.                       FLD->col, FLD->prmpt, 
  115.                       FLD->atrib, FLD->fill, FLD->v1.vuip, FLD->v2.vi, 
  116.                       FLD->v3.vui, FLD->v4.vui, FLD->v5.vcp,
  117.                       FLD->v6.vcp,FLD->v7.vcp);
  118.         break;
  119.       case GLONG:
  120.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  121.           wns_ierr("wm_frmget@GLONG");
  122.         rv = wn_glong(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  123.                       FLD->col, FLD->prmpt, 
  124.                       FLD->atrib, FLD->fill, FLD->v1.vlp, FLD->v2.vi, 
  125.                       FLD->v3.vl, FLD->v4.vl, FLD->v5.vcp,
  126.                       FLD->v6.vcp,FLD->v7.vcp);
  127.         break;
  128.       case GULONG:
  129.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  130.           wns_ierr("wm_frmget@GULONG");
  131.         rv = wn_gulong(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  132.                       FLD->col, FLD->prmpt, 
  133.                       FLD->atrib, FLD->fill, FLD->v1.vulp, FLD->v2.vi, 
  134.                       FLD->v3.vul, FLD->v4.vul, FLD->v5.vcp,
  135.                       FLD->v6.vcp,FLD->v7.vcp);
  136.         break;
  137.       case GFLOAT:
  138.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  139.           wns_ierr("wm_frmget@GFLOAT");
  140.         rv = wn_gfloat(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  141.                        FLD->col, FLD->prmpt, 
  142.                        FLD->atrib, FLD->fill, FLD->v1.vfp, FLD->v2.vi, 
  143.                        FLD->v3.vi, FLD->v4.vf, FLD->v5.vf, FLD->v6.vcp,
  144.                        FLD->v7.vcp,FLD->v8.vcp);
  145.         break;
  146.       case GDOUBL:
  147.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  148.           wns_ierr("wm_frmget@GDOUBL");
  149.         rv = wn_gdouble(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  150.                        FLD->col, FLD->prmpt, 
  151.                        FLD->atrib, FLD->fill, FLD->v1.vdp, FLD->v2.vi, 
  152.                        FLD->v3.vi, FLD->v4.vd, FLD->v5.vd, FLD->v6.vcp,
  153.                        FLD->v7.vcp,FLD->v8.vcp);
  154.         break;
  155.       case GPHONE:
  156.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  157.           wns_ierr("wm_frmget@GPHONE");
  158.         rv = wn_gphone(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  159.                        FLD->col, FLD->prmpt, 
  160.                        FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  161.                        FLD->v3.vip, FLD->v4.vcp,
  162.                        FLD->v5.vcp,FLD->v6.vcp);
  163.         break;
  164.       case GTEXT:
  165.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  166.           wns_ierr("wm_frmget@GTEXT");
  167.         rv = wn_gtext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  168.                       FLD->col, FLD->prmpt, 
  169.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  170.                       FLD->v3.vcp,FLD->v4.vcp);
  171.         break;
  172.       case GUTEXT:
  173.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  174.           wns_ierr("wm_frmget@GUTEXT");
  175.         rv = wn_gutext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  176.                       FLD->col, FLD->prmpt, 
  177.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  178.                       FLD->v3.vcp,FLD->v4.vcp);
  179.         break;
  180.       case GLTEXT:
  181.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  182.           wns_ierr("wm_frmget@GLTEXT");
  183.         rv = wn_gltext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  184.                       FLD->col, FLD->prmpt, 
  185.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  186.                       FLD->v3.vcp,FLD->v4.vcp);
  187.         break;
  188.       case GATEXT:
  189.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  190.           wns_ierr("wm_frmget@GATEXT");
  191.         rv = wn_gatext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  192.                       FLD->col, FLD->prmpt, 
  193.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vucp,
  194.                       FLD->v3.vucp,FLD->v4.vucp);
  195.         break;
  196.       case GBOOL:
  197.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  198.           wns_ierr("wm_frmget@GBOOL");
  199.         rv = wn_gbool(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  200.                       FLD->col, FLD->prmpt, 
  201.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vcp,
  202.                       FLD->v3.vcp,FLD->v4.vcp);
  203.         break;
  204.       case DTEXT:                       /* display text */
  205.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  206.           wns_ierr("wm_frmget@DTEXT");
  207.         rv = wn_dtext(XEQ,NFRM,NFLD,FLD->wn, FLD->row, FLD->col, FLD->prmpt);
  208.         break;
  209.       case GPWORD:
  210.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  211.           wns_ierr("wm_frmget@GPWORD");
  212.         rv = wn_gpword(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  213.                       FLD->col, FLD->prmpt, 
  214.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  215.                       FLD->v3.vcp,FLD->v4.vcp);
  216.         break;
  217.     }                                   /* end switch(frm.code) */
  218.     if(rv != BKTAB && rv != UARROW)     /* previous field ?? */
  219.       indx++;                           /* no, just bump index */
  220.     else {                              /* previous field request */
  221.       indx--;                           /* decrement index */
  222.       if(indx <= 0) indx = 0;           /* but dont be stupid! */
  223.     }
  224.     if(rv == ESC)                       /* Escape backout - ESC.001 */
  225.       return(ESC_CODE);                 /* Escape backout - ESC.001 */
  226.   }
  227.  
  228.   if(wni_frmflg) {                      /* first pass thru */
  229.     wni_frmflg = FALSE;                 /* displays prompts & data */
  230.     goto begin;                         /* now, lets *really* read */
  231.   }
  232.  
  233. /*************************************************************************
  234. *                                                                        *
  235. *                  CUSTOMIZE THE SECTION BELOW ONLY                      *
  236. *                                                                        *
  237. **************************************************************************/
  238.  
  239.                                         /* PRESS Return Stuff */
  240.   wn=wn_open(1000,(wni_mxrows-1),0,(int)strlen(msg),1,(RVIDEO),NVIDEO);
  241.   if(!wn) exit(1);
  242.   wn_puts(wn,0,0,msg);                  /* display message */
  243.   c = v_getch() & 0xff;                 /* fetch response */
  244.   wn_close(wn);                         /* make message go away */
  245.   if(c == CR)                           /* ENTER ?? */
  246.     return(TRUE);                       /* return if so */
  247.   if(c == ESC)                          /* Escape Backout - ESC.001 */
  248.     return(ESC_CODE);                   /* Escape Backout - ESC.001 */
  249.   else                                  /* else edit the */
  250.     goto begin;                         /* form ! */
  251. }     
  252.  
  253. /* End */
  254.